﻿using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class header : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        /*
        if (Convert.ToString(Session["username"]) != "")
        {
            userstate.Visible = false;
            welcoming.Visible = true;
            User_Name.Visible = true;
            User_Name.Text = Convert.ToString(Session["username"]);
            User_Name.NavigateUrl = "";
            Label1.Visible = false;
            username.Visible = false;
            Label2.Visible = false;
            userpassword.Visible = false;

            Label3.Visible = false;
            txtCheckCode.Visible = false;
            lblMessage.Visible = false;
            check_pic.Visible = false;
            Button1.Visible = false;
            Button3.Visible = true;
        }*/
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
    /*
       
        if (Request.Cookies["CheckCode"] == null)
        {
            lblMessage.Text = "您的浏览器设置已被禁用 Cookies，您必须设置浏览器允许使用 Cookies 选项后才能使用本系统。";
            lblMessage.Visible = true;
            return;
        }

        if (String.Compare(Request.Cookies["CheckCode"].Value, txtCheckCode.Text, true) != 0)
        {
            lblMessage.Text = "*验证码错误";
            lblMessage.Visible = true;
            return;
        }
        OleDbConnection Conn = new OleDbConnection();
        Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Server.MapPath("miumiu.mdb");
        Conn.Open();

        string pwd = userpassword.Text;
        string pwd_md5 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(pwd, "md5");
        string logining = "select count(*) from user_info where username='" + username.Text + "' and userpassword='" + pwd_md5 + "'";
        OleDbCommand dap = new OleDbCommand(logining, Conn);
        int count = (int)dap.ExecuteScalar();
        if (count > 0)
        {
            Session["username"] = username.Text.ToString();
            Conn.Close();
            Response.Write("<script>alert('登录成功！欢迎你，'+'" + username.Text + "'+'！');location='index.aspx'</script>");
        }
        else
        {
            Conn.Close();
            Response.Write("<script>alert('用户名或者密码输入有误，请重新输入！');location='index.aspx'</script>");
        }
    */    
    }

    protected void Button3_Click(object sender, EventArgs e)
    {
        /*if (Convert.ToString(Session["username"]) != "")
        {
            Session["username"] = "";
            Response.Redirect("index.aspx");
        }
        */
    }

}
